# Build stage
FROM golang:1.21-alpine AS builder

WORKDIR /app

# Install build dependencies
RUN apk add --no-cache git

# Copy go mod files
COPY go.mod go.sum ./

# Download dependencies
RUN go mod download

# Copy source code
COPY . .

# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -o metrics-collect

# Final stage
FROM alpine:latest

WORKDIR /app

# Copy the binary from builder
COPY --from=builder /app/metrics-collect .
# Copy default config
COPY config.yaml .

# Expose prometheus metrics port
EXPOSE 9090

# Run the binary
ENTRYPOINT ["./metrics-collect"] 